//
//  HomeCell.swift
//  WeiBo
//
//  Created by Tony on 2018/1/22.
//  Copyright © 2018年 Tony. All rights reserved.
//

import UIKit
import SDWebImage

class HomeCell: UITableViewCell {

    
    // 属性
    @IBOutlet weak var iconView: UIImageView!
    @IBOutlet weak var verifiedView: UIImageView!
    @IBOutlet weak var screenNameLabel: UILabel!
    @IBOutlet weak var vipView: UIImageView!
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var sourceLabel: UILabel!
    @IBOutlet weak var contentLabel: UILabel!
    
    @IBOutlet weak var contentLabelWidth: NSLayoutConstraint!
    var viewModel: StatusViewModel? {
        didSet {
            
            // 空值较验
            guard let viewModel = viewModel  else {
                return
            }
            // 设置
            iconView.sd_setImage(with: viewModel.profileUrl, placeholderImage: UIImage.init(named: "avatar_default_small"))
            verifiedView.image = viewModel.verified_image;
            screenNameLabel.text = viewModel.status?.user?.screen_name ?? ""
            vipView.image = viewModel.vip_image
            timeLabel.text = viewModel.created_atText
            sourceLabel.text = viewModel.sourceText
            contentLabel.text = viewModel.status?.text
            
        }
    }
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        contentLabelWidth.constant = UIScreen.main.bounds.width - 2 * 13
    }

    

}
